//
//  YDVerticalStockDetailView.m
//  PeiZiWangBei
//
//  Created by LK-IOS on 2018/1/7.
//  Copyright © 2018年 LK-IOS. All rights reserved.
//

#import "YDVerticalStockDetailView.h"


@interface YDVerticalStockDetailView()<SYVerticalStockButtonOptionViewDelegate>

/**
 今开等小数据距离左边的间距
 */
@property (nonatomic , assign) CGFloat leftMargin;
/**
 今开等小数据间的横向间距
 */
@property (nonatomic , assign) CGFloat margin;

/**
 今开等小数据的宽度
 */
@property (nonatomic , assign) CGFloat labelWidth;

/**
 代码
 */
@property (nonatomic , weak) UILabel *stockCode;

/**
 名称
 */
@property (nonatomic , weak) UILabel *stockName;

/**
 加自选
 */
@property (nonatomic , weak) SYNoHeightedButton *addOptionButton;

/**
 股票最新价
 */
@property (nonatomic , weak) UILabel *stockNewPrice;

/**
 价格变动幅度
 */
@property (nonatomic , weak) UILabel *stockPriceChange;

/**
 价格变动幅度百分比
 */
@property (nonatomic , weak) UILabel *stockPriceChangeRate;

/**
 今开
 */
@property (nonatomic , weak) UILabel *openPrice;

/**
 昨收
 */
@property (nonatomic , weak) UILabel *yesClosePrice;

/**
 最高
 */
@property (nonatomic , weak) UILabel *maxPrice;

/**
 最低
 */
@property (nonatomic , weak) UILabel *minPrice;

/**
 涨停
 */
@property (nonatomic , weak) UILabel *upStopPrice;

/**
 跌停
 */
@property (nonatomic , weak) UILabel *downStopPrice;


/**
 显示按钮的View
 */
@property (nonatomic , weak) YDVerticalStockButtonOptionView *optionView;

@end

@implementation YDVerticalStockDetailView

-(void)setStockDict:(NSDictionary *)stockDict
{
    _stockDict = stockDict;
    
    DDLog(@"stockDict = %@" ,stockDict)
    //有没有加过自选
    if ([stockDict[@"favorite"] boolValue]) {
        self.addOptionButton.selected = YES;
    }else{
        self.addOptionButton.selected = NO;;
    }
    //名称及代码
    self.stockName.text = [NSString stringWithFormat:@"%@" , stockDict[@"name"]];
    self.stockCode.text = [NSString stringWithFormat:@"%@" , stockDict[@"instrumentId"]];
    //当前价 , 变化值 变化幅度
    NSString *lastPriceString;
    if (stockDict[@"lastPrice"]) {
        NSString *lastPrice = [[NSString stringWithFormat:@"%@" , stockDict[@"lastPrice"]] pz_stringNumberByMultiplyingBy:@"1"];
        lastPriceString = [NSString stringWithFormat:@"%@" , lastPrice];
    }else{
        lastPriceString = [NSString stringWithFormat:@"---"];
    }
    self.stockNewPrice.text = lastPriceString;
    
    NSString *upDropPriceString;
    if (stockDict[@"upDropPrice"]) {
        NSString *upDropPrice = [[NSString stringWithFormat:@"%@" , stockDict[@"upDropPrice"]] pz_stringNumberByMultiplyingBy:@"1"];
        upDropPriceString = [NSString stringWithFormat:@"%@" , upDropPrice];
    }else{
        upDropPriceString = [NSString stringWithFormat:@"---"];
    }
    self.stockPriceChange.text = upDropPriceString;
    
    
    NSString *upDropSpeedString;
    if (stockDict[@"upDropSpeed"]) {
        NSString *upDropSpeed = [[NSString stringWithFormat:@"%@" , stockDict[@"upDropSpeed"]] pz_stringNumberByMultiplyingBy:@"100"];
        upDropSpeedString = [NSString stringWithFormat:@"%@%@" , upDropSpeed , @"%"];
    }else{
        upDropSpeedString = [NSString stringWithFormat:@"---"];
    }
    self.stockPriceChangeRate.text = upDropSpeedString;
    
    BOOL isUp;
    //颜色设置
    if (stockDict[@"upDropSpeed"] && [stockDict[@"upDropSpeed"] floatValue] >0) {
        self.stockNewPrice.textColor = [UIColor colorWithHexString:stockRed];
        self.stockPriceChange.textColor = [UIColor colorWithHexString:stockRed];
        self.stockPriceChangeRate.textColor = [UIColor colorWithHexString:stockRed];
        isUp = YES;
    }else{
        self.stockNewPrice.textColor = [UIColor colorWithHexString:stockGreen];
        self.stockPriceChange.textColor = [UIColor colorWithHexString:stockGreen];
        self.stockPriceChangeRate.textColor = [UIColor colorWithHexString:stockGreen];
        isUp = NO;
    }
    
    
    //今开  左收
    NSString *openPriceString;
    NSAttributedString *aopenPriceString;
    if (stockDict[@"openPrice"]) {
        NSString *openPrice = [[NSString stringWithFormat:@"%@" , stockDict[@"openPrice"]] pz_stringNumberByMultiplyingBy:@"1"];
        openPriceString = [NSString stringWithFormat:@"%@ %@" , @"今开" , openPrice];
        if (isUp) {
            aopenPriceString = [NSString getAttriNeedChangeString:[NSString stringWithFormat:@" %@" , openPrice] changeColor:[UIColor colorWithHexString:stockRed] changeFont:[UIFont boldSystemFontOfSize:font12ScreenWRate * LKScreenW] sourceString:openPriceString];
        }else{
            aopenPriceString = [NSString getAttriNeedChangeString:[NSString stringWithFormat:@" %@" , openPrice] changeColor:[UIColor colorWithHexString:stockGreen] changeFont:[UIFont boldSystemFontOfSize:font12ScreenWRate * LKScreenW] sourceString:openPriceString];
        }

    }else{
        openPriceString = [NSString stringWithFormat:@"%@ %@" , @"今开" , @"---"];
        if (isUp) {
            aopenPriceString = [NSString getAttriNeedChangeString:[NSString stringWithFormat:@" %@" , @"---"] changeColor:[UIColor colorWithHexString:stockRed] changeFont:[UIFont boldSystemFontOfSize:font12ScreenWRate * LKScreenW] sourceString:openPriceString];
        }else{
            aopenPriceString = [NSString getAttriNeedChangeString:[NSString stringWithFormat:@" %@" , @"---"] changeColor:[UIColor colorWithHexString:stockGreen] changeFont:[UIFont boldSystemFontOfSize:font12ScreenWRate * LKScreenW] sourceString:openPriceString];
        }
    }
    self.openPrice.attributedText = aopenPriceString;
    
    NSString *preClsPriceString;
    NSAttributedString *apreClsPriceString;
    if (stockDict[@"preClsPrice"]) {
        NSString *preClsPrice = [[NSString stringWithFormat:@"%@" , stockDict[@"preClsPrice"]] pz_stringNumberByMultiplyingBy:@"1"];
        preClsPriceString = [NSString stringWithFormat:@"%@ %@" , @"昨收" , preClsPrice];
        if (isUp) {
            apreClsPriceString = [NSString getAttriNeedChangeString:[NSString stringWithFormat:@" %@" , preClsPrice] changeColor:[UIColor colorWithHexString:stockRed] changeFont:[UIFont boldSystemFontOfSize:font12ScreenWRate * LKScreenW] sourceString:preClsPriceString];
        }else{
            apreClsPriceString = [NSString getAttriNeedChangeString:[NSString stringWithFormat:@" %@" , preClsPrice] changeColor:[UIColor colorWithHexString:stockGreen] changeFont:[UIFont boldSystemFontOfSize:font12ScreenWRate * LKScreenW] sourceString:preClsPriceString];
        }
    }else{
        preClsPriceString = [NSString stringWithFormat:@"%@ %@" , @"昨收" , @"---"];
        if (isUp) {
            apreClsPriceString = [NSString getAttriNeedChangeString:[NSString stringWithFormat:@" %@" , @"---"] changeColor:[UIColor colorWithHexString:stockRed] changeFont:[UIFont boldSystemFontOfSize:font12ScreenWRate * LKScreenW] sourceString:preClsPriceString];
        }else{
            apreClsPriceString = [NSString getAttriNeedChangeString:[NSString stringWithFormat:@" %@" , @"---"] changeColor:[UIColor colorWithHexString:stockGreen] changeFont:[UIFont boldSystemFontOfSize:font12ScreenWRate * LKScreenW] sourceString:preClsPriceString];
        }
    }
    self.yesClosePrice.attributedText = apreClsPriceString;
    
    //最高  最低
    NSString *highestPriceString;
    NSAttributedString *ahighestPriceString;
    if (stockDict[@"highestPrice"]) {
        NSString *highestPrice = [[NSString stringWithFormat:@"%@" , stockDict[@"highestPrice"]] pz_stringNumberByMultiplyingBy:@"1"];
        highestPriceString = [NSString stringWithFormat:@"%@ %@" , @"最高" , highestPrice];
        if (isUp) {
            ahighestPriceString = [NSString getAttriNeedChangeString:[NSString stringWithFormat:@" %@" , highestPrice] changeColor:[UIColor colorWithHexString:stockRed] changeFont:[UIFont boldSystemFontOfSize:font12ScreenWRate * LKScreenW] sourceString:highestPriceString];
        }else{
            ahighestPriceString = [NSString getAttriNeedChangeString:[NSString stringWithFormat:@" %@" , highestPrice] changeColor:[UIColor colorWithHexString:stockGreen] changeFont:[UIFont boldSystemFontOfSize:font12ScreenWRate * LKScreenW] sourceString:highestPriceString];
        }
    }else{
        highestPriceString = [NSString stringWithFormat:@"%@ %@" , @"最高" , @"---"];
        if (isUp) {
            ahighestPriceString = [NSString getAttriNeedChangeString:[NSString stringWithFormat:@" %@" , @"---"] changeColor:[UIColor colorWithHexString:stockRed] changeFont:[UIFont boldSystemFontOfSize:font12ScreenWRate * LKScreenW] sourceString:highestPriceString];
        }else{
            ahighestPriceString = [NSString getAttriNeedChangeString:[NSString stringWithFormat:@" %@" , @"---"] changeColor:[UIColor colorWithHexString:stockGreen] changeFont:[UIFont boldSystemFontOfSize:font12ScreenWRate * LKScreenW] sourceString:highestPriceString];
        }
    }
    self.maxPrice.attributedText = ahighestPriceString;
    
    NSString *lowestPriceString;
    NSAttributedString *alowestPriceString;
    if (stockDict[@"lowestPrice"]) {
        NSString *lowestPrice = [[NSString stringWithFormat:@"%@" , stockDict[@"lowestPrice"]] pz_stringNumberByMultiplyingBy:@"1"];
        lowestPriceString = [NSString stringWithFormat:@"%@ %@" , @"最低" , lowestPrice];
        if (isUp) {
            alowestPriceString = [NSString getAttriNeedChangeString:[NSString stringWithFormat:@" %@" , lowestPrice] changeColor:[UIColor colorWithHexString:stockRed] changeFont:[UIFont boldSystemFontOfSize:font12ScreenWRate * LKScreenW] sourceString:lowestPriceString];
        }else{
            alowestPriceString = [NSString getAttriNeedChangeString:[NSString stringWithFormat:@" %@" , lowestPrice] changeColor:[UIColor colorWithHexString:stockGreen] changeFont:[UIFont boldSystemFontOfSize:font12ScreenWRate * LKScreenW] sourceString:lowestPriceString];
        }
    }else{
        lowestPriceString = [NSString stringWithFormat:@"%@ %@" , @"最低" , @"---"];
        if (isUp) {
            alowestPriceString = [NSString getAttriNeedChangeString:[NSString stringWithFormat:@" %@" , @"---"] changeColor:[UIColor colorWithHexString:stockRed] changeFont:[UIFont boldSystemFontOfSize:font12ScreenWRate * LKScreenW] sourceString:lowestPriceString];
        }else{
            alowestPriceString = [NSString getAttriNeedChangeString:[NSString stringWithFormat:@" %@" , @"---"] changeColor:[UIColor colorWithHexString:stockGreen] changeFont:[UIFont boldSystemFontOfSize:font12ScreenWRate * LKScreenW] sourceString:lowestPriceString];
        }
    }
    self.minPrice.attributedText =alowestPriceString;
    
    //涨停 跌停
    NSString *upLimitPriceString;
    NSAttributedString *aupLimitPriceString;
    if (stockDict[@"upLimitPrice"]) {
        NSString *upLimitPrice = [[NSString stringWithFormat:@"%@" , stockDict[@"upLimitPrice"]] pz_stringNumberByMultiplyingBy:@"1"];
        upLimitPriceString = [NSString stringWithFormat:@"%@ %@" , @"涨停" , upLimitPrice];
        aupLimitPriceString = [NSString getAttriNeedChangeString:[NSString stringWithFormat:@" %@" , upLimitPrice] changeColor:[UIColor colorWithHexString:stockRed] changeFont:[UIFont boldSystemFontOfSize:font12ScreenWRate * LKScreenW] sourceString:upLimitPriceString];
    }else{
        upLimitPriceString = [NSString stringWithFormat:@"%@ %@" , @"涨停" , @"---"];
        aupLimitPriceString = [NSString getAttriNeedChangeString:[NSString stringWithFormat:@" %@" , @"---"] changeColor:[UIColor colorWithHexString:stockRed] changeFont:[UIFont boldSystemFontOfSize:font12ScreenWRate * LKScreenW] sourceString:upLimitPriceString];
    }

    self.upStopPrice.attributedText = aupLimitPriceString;
    
    NSString *downLimitPriceString;
    NSAttributedString *adownLimitPriceString;
    if (stockDict[@"downLimitPrice"]) {
        NSString *downLimitPrice = [[NSString stringWithFormat:@"%@" , stockDict[@"downLimitPrice"]] pz_stringNumberByMultiplyingBy:@"1"];
        downLimitPriceString = [NSString stringWithFormat:@"%@ %@" , @"跌停" , downLimitPrice];
        adownLimitPriceString = [NSString getAttriNeedChangeString:[NSString stringWithFormat:@" %@" , downLimitPrice] changeColor:[UIColor colorWithHexString:stockGreen] changeFont:[UIFont boldSystemFontOfSize:font12ScreenWRate * LKScreenW] sourceString:downLimitPriceString];
    }else{
        downLimitPriceString = [NSString stringWithFormat:@"%@ %@" , @"跌停" , @"---"];
        adownLimitPriceString = [NSString getAttriNeedChangeString:[NSString stringWithFormat:@" %@" , @"---"] changeColor:[UIColor colorWithHexString:stockGreen] changeFont:[UIFont boldSystemFontOfSize:font12ScreenWRate * LKScreenW] sourceString:downLimitPriceString];
    }
    self.downStopPrice.attributedText =adownLimitPriceString;
    
    

    
}
-(void)setStockNameS:(NSString *)stockNameS
{
    _stockNameS = stockNameS;
    self.stockName.text = stockNameS;
}
-(void)setStockCodeS:(NSString *)stockCodeS
{
    _stockCodeS = stockCodeS;
    self.stockCode.text = stockCodeS;
}

-(void)setOptionViewStyle:(SYVerticalStockButtonOptionViewStyle)optionViewStyle
{
    _optionViewStyle = optionViewStyle;
    
    self.optionView.optionViewStyle = optionViewStyle;
}

-(void)setIsActivity:(BOOL)isActivity
{
    _isActivity = isActivity;
    
    if (isActivity) {
        self.addOptionButton.hidden = YES;
    }else{
        self.addOptionButton.hidden = NO;
    }
}
-(void)setIsNormal:(BOOL)isNormal
{
    isNormal = isNormal;
    
    if (isNormal) {
        self.addOptionButton.hidden = YES;
        self.optionView.hidden = NO;
    }else{
        self.optionView.hidden = YES;
        self.addOptionButton.hidden = NO;
    }

}
-(instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor whiteColor];
        [self initConfig];
        [self initUI];
    }
    return self;
}

/**
 属性设置
 */
-(void)initConfig
{
    self.leftMargin = rate375(135);
    self.margin = rate375(20);
    self.labelWidth = (LKScreenW - self.leftMargin - 3 * self.margin) / 3;
}

/*****添加控件********/
-(void)initUI
{
    [self stockCode];
    [self stockName];
    [self addOptionButton];
    [self stockNewPrice];
    [self stockPriceChange];
    [self stockPriceChangeRate];
    [self openPrice];
    [self yesClosePrice];
    [self maxPrice];
    [self minPrice];
    [self upStopPrice];
    [self downStopPrice];
    [self optionView];
}

+(instancetype)verticalStockDetailViewWithStockDict:(NSDictionary *)stockDict StockName:(NSString *)stockName StockCode:(NSString *)stockCode IsActivity:(BOOL)isActivity IsNormal:(BOOL)isNormal OptionViewStyle:(SYVerticalStockButtonOptionViewStyle)optionViewStyle
{
    YDVerticalStockDetailView *detailView = [[YDVerticalStockDetailView alloc] init];
    detailView.stockDict = stockDict;
    detailView.stockNameS = stockName;
    detailView.stockCodeS = stockCode;
    detailView.isActivity = isActivity;
    detailView.isNormal = isNormal;
    detailView.optionViewStyle = optionViewStyle;
    return detailView;
}

-(UILabel *)stockCode
{
    if (_stockCode == nil) {
        UILabel *stockCode = [[UILabel alloc] init];
        [self addSubview:stockCode];
        stockCode.textColor = [UIColor colorWithHexString:dark];
        stockCode.font = [UIFont systemFontOfSize:font12ScreenWRate * LKScreenW];
        stockCode.textAlignment = NSTextAlignmentLeft;
        stockCode.text = @"------";
        [stockCode mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self).offset(rate375(15));
            if (isPhoneX) {
                make.top.equalTo(self).offset(rateX812(18));
            }else{
                make.top.equalTo(self).offset(rate750(18));
            }
        }];
        _stockCode = stockCode;
    }
    return _stockCode;
}

-(UILabel *)stockName
{
    if (_stockName == nil) {
        UILabel *stockName = [[UILabel alloc] init];
        [self addSubview:stockName];
        stockName.textColor = [UIColor colorWithHexString:dark];
        stockName.font = [UIFont systemFontOfSize:font18ScreenWRate * LKScreenW];
        stockName.textAlignment = NSTextAlignmentLeft;
        stockName.text = @"----";
        [stockName mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.stockCode.mas_right).offset(rate375(5));
            make.centerY.equalTo(self.stockCode);
        }];
        _stockName = stockName;
    }
    return _stockName;
}

-(SYNoHeightedButton *)addOptionButton
{
    if (_addOptionButton == nil) {
        SYNoHeightedButton *addOptionButton = [SYNoHeightedButton buttonWithType:UIButtonTypeCustom];
        [self addSubview:addOptionButton];
        addOptionButton.backgroundColor = [UIColor clearColor];
        [addOptionButton setImage:[UIImage imageNamed:@"dm-tianjia"] forState:UIControlStateNormal];
        [addOptionButton setImage:[UIImage imageNamed:@"dm-shanjian"] forState:UIControlStateSelected];
        [addOptionButton mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.stockName.mas_right).offset(rate375(10));
            make.height.width.equalTo(@(rate375(20)));
            make.centerY.equalTo(self.stockCode);
        }];
        [addOptionButton addTarget:self action:@selector(optionButtonClick:) forControlEvents:UIControlEventTouchDown];
        
        _addOptionButton = addOptionButton;
    }
    return _addOptionButton;
}
-(void)optionButtonClick:(SYNoHeightedButton *)button
{
    if (self.delegate && [self.delegate respondsToSelector:@selector(didSlectedBtn:)]) {
        [self.delegate didSlectedBtn:@"自选"];
    }
}

-(UILabel *)stockNewPrice
{
    if (_stockNewPrice == nil) {
        UILabel *stockNewPrice = [[UILabel alloc] init];
        [self addSubview:stockNewPrice];
        stockNewPrice.textColor = [UIColor colorWithHexString:stockRed];
        stockNewPrice.font = [UIFont boldSystemFontOfSize:font32ScreenWRate * LKScreenW];
        stockNewPrice.textAlignment = NSTextAlignmentCenter;
        stockNewPrice.text = @"-----";
        [stockNewPrice mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self).offset(rate375(15));
            if (isPhoneX) {
                make.top.equalTo(self.stockCode.mas_bottom).offset(rateX812(12));
            }else{
                make.top.equalTo(self.stockCode.mas_bottom).offset(rate750(12));
            }
            make.width.equalTo(@(rate375(85)));
        }];
        stockNewPrice.adjustsFontSizeToFitWidth = YES;
        _stockNewPrice = stockNewPrice;
    }
    return _stockNewPrice;
}
-(UILabel *)stockPriceChange
{
    if (_stockPriceChange == nil) {
        UILabel *stockPriceChange = [[UILabel alloc] init];
        [self addSubview:stockPriceChange];
        stockPriceChange.textColor = [UIColor colorWithHexString:stockRed];
        stockPriceChange.font = [UIFont boldSystemFontOfSize:font12ScreenWRate * LKScreenW];
        stockPriceChange.textAlignment = NSTextAlignmentLeft;
        stockPriceChange.text = @"----";
        [stockPriceChange mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.stockNewPrice);
            make.top.equalTo(self.stockNewPrice.mas_bottom);
            make.right.equalTo(self.stockNewPrice.mas_centerX).offset(-rate375(2));
        }];
        stockPriceChange.adjustsFontSizeToFitWidth = YES;
        _stockPriceChange = stockPriceChange;
    }
    return _stockPriceChange;
}
-(UILabel *)stockPriceChangeRate
{
    if (_stockPriceChangeRate == nil) {
        UILabel *stockPriceChangeRate = [[UILabel alloc] init];
        [self addSubview:stockPriceChangeRate];
        stockPriceChangeRate.textColor = [UIColor colorWithHexString:stockRed];
        stockPriceChangeRate.font = [UIFont boldSystemFontOfSize:font12ScreenWRate * LKScreenW];
        stockPriceChangeRate.textAlignment = NSTextAlignmentRight;
        stockPriceChangeRate.text = @"----";
        [stockPriceChangeRate mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self.stockNewPrice.mas_right);
            make.top.equalTo(self.stockNewPrice.mas_bottom);
            make.left.equalTo(self.stockNewPrice.mas_centerX).offset(rate375(2));
        }];
        stockPriceChangeRate.adjustsFontSizeToFitWidth = YES;
        _stockPriceChangeRate = stockPriceChangeRate;
    }
    return _stockPriceChangeRate;
}

-(UILabel *)openPrice
{
    if (_openPrice == nil) {
        UILabel *openPrice = [[UILabel alloc] init];
        [self addSubview:openPrice];
        openPrice.textColor = [UIColor colorWithHexString:blueyGrey];
        openPrice.font = [UIFont boldSystemFontOfSize:font12ScreenWRate * LKScreenW];
        openPrice.textAlignment = NSTextAlignmentLeft;
        openPrice.text = @"今开 ---";
        [openPrice mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self).offset(self.leftMargin);
            make.width.equalTo(@(self.labelWidth));
            make.centerY.equalTo(self.stockNewPrice);
        }];
        openPrice.adjustsFontSizeToFitWidth = YES;
        _openPrice = openPrice;
    }
    return _openPrice;
}
-(UILabel *)yesClosePrice
{
    if (_yesClosePrice == nil) {
        UILabel *yesClosePrice = [[UILabel alloc] init];
        [self addSubview:yesClosePrice];
        yesClosePrice.textColor = [UIColor colorWithHexString:blueyGrey];
        yesClosePrice.font = [UIFont boldSystemFontOfSize:font12ScreenWRate * LKScreenW];
        yesClosePrice.textAlignment = NSTextAlignmentLeft;
        yesClosePrice.text = @"昨收 ---";
        [yesClosePrice mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.openPrice);
            make.width.equalTo(@(self.labelWidth));
            make.bottom.equalTo(self.stockPriceChangeRate);
        }];
        yesClosePrice.adjustsFontSizeToFitWidth = YES;
        _yesClosePrice = yesClosePrice;
    }
    return _yesClosePrice;
}
-(UILabel *)maxPrice
{
    if (_maxPrice == nil) {
        UILabel *maxPrice = [[UILabel alloc] init];
        [self addSubview:maxPrice];
        maxPrice.textColor = [UIColor colorWithHexString:blueyGrey];
        maxPrice.font = [UIFont boldSystemFontOfSize:font12ScreenWRate * LKScreenW];
        maxPrice.textAlignment = NSTextAlignmentLeft;
        maxPrice.text = @"最高 ---";
        [maxPrice mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.openPrice.mas_right).offset(self.margin);
            make.width.equalTo(@(self.labelWidth));
            make.centerY.equalTo(self.stockNewPrice);
        }];
        maxPrice.adjustsFontSizeToFitWidth = YES;
        _maxPrice = maxPrice;
    }
    return _maxPrice;
}
-(UILabel *)minPrice
{
    if (_minPrice == nil) {
        UILabel *minPrice = [[UILabel alloc] init];
        [self addSubview:minPrice];
        minPrice.textColor = [UIColor colorWithHexString:blueyGrey];
        minPrice.font = [UIFont boldSystemFontOfSize:font12ScreenWRate * LKScreenW];
        minPrice.textAlignment = NSTextAlignmentLeft;
        minPrice.text = @"最低 ---";
        [minPrice mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.yesClosePrice.mas_right).offset(self.margin);
            make.width.equalTo(@(self.labelWidth));
            make.bottom.equalTo(self.stockPriceChangeRate);
        }];
        minPrice.adjustsFontSizeToFitWidth = YES;
        _minPrice = minPrice;
    }
    return _minPrice;
}
-(UILabel *)upStopPrice
{
    if (_upStopPrice == nil) {
        UILabel *upStopPrice = [[UILabel alloc] init];
        [self addSubview:upStopPrice];
        upStopPrice.textColor = [UIColor colorWithHexString:blueyGrey];
        upStopPrice.font = [UIFont boldSystemFontOfSize:font12ScreenWRate * LKScreenW];
        upStopPrice.textAlignment = NSTextAlignmentLeft;
        upStopPrice.text = @"涨停 ---";
        [upStopPrice mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.maxPrice.mas_right).offset(self.margin);
            make.width.equalTo(@(self.labelWidth));
            make.centerY.equalTo(self.stockNewPrice);
        }];
        upStopPrice.adjustsFontSizeToFitWidth = YES;
        _upStopPrice = upStopPrice;
    }
    return _upStopPrice;
}
-(UILabel *)downStopPrice
{
    if (_downStopPrice == nil) {
        UILabel *downStopPrice = [[UILabel alloc] init];
        [self addSubview:downStopPrice];
        downStopPrice.textColor = [UIColor colorWithHexString:blueyGrey];
        downStopPrice.font = [UIFont boldSystemFontOfSize:font12ScreenWRate * LKScreenW];
        downStopPrice.textAlignment = NSTextAlignmentLeft;
        downStopPrice.text = @"跌停 ---";
        [downStopPrice mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.minPrice.mas_right).offset(self.margin);
            make.width.equalTo(@(self.labelWidth));
            make.bottom.equalTo(self.stockPriceChangeRate);
        }];
        downStopPrice.adjustsFontSizeToFitWidth = YES;
        _downStopPrice = downStopPrice;
    }
    return _downStopPrice;
}

-(YDVerticalStockButtonOptionView *)optionView
{
    if (_optionView == nil) {
        YDVerticalStockButtonOptionView *optionView = [YDVerticalStockButtonOptionView verticalStockButtonOptionViewWithButtonOptionViewStyle:self.optionViewStyle];
        [self addSubview:optionView];
        optionView.delegate = self;
        optionView.backgroundColor = [UIColor clearColor];
        [optionView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self).offset(-rate375(15));
            make.centerY.equalTo(self.stockCode);
            make.width.equalTo(@(rate375(168)));
            if (isPhoneX) {
                make.height.equalTo(@(rateX812(28)));
            }else{
                make.height.equalTo(@(rate750(28)));
            }
        }];
        
        
        _optionView = optionView;
    }
    return _optionView;
}

#pragma SYVerticalStockButtonOptionViewDelegate
-(void)verticalStockButtonOptionView:(YDVerticalStockButtonOptionView *)optionView withButtonTitle:(NSString *)buttonTitle
{
    
    if (self.delegate && [self.delegate respondsToSelector:@selector(didSlectedBtn:)]) {
        [self.delegate didSlectedBtn:buttonTitle];
    }
    
}

@end
